﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.Web.Script.Serialization;
namespace Wekit.Web.Result
{
    /// <summary>
    /// 实现JQuery的跨域访问功能
    /// </summary>
   public   class JsonpResult:ActionResult
    {
       private object Data { get; set; }

       public JsonpResult(object data)
       {
           Data = data;
       }


       public override void ExecuteResult(ControllerContext context)
       {
           context.HttpContext.Response.Write(
               string.Format("{0}({1});",
               context.HttpContext.Request["callback"],
               new JavaScriptSerializer().Serialize(Data)
               ));
       }
    }
}
